var entityCollection = require('../../../Base/server/controllers/EntityCollection');
 
//根据根据工单ID查找全部看板需求
exports.findOneByMoId = function(MoId, completeFun) {
    var entity = entityCollection.getEntity("KanbanDemand");
    entity.findOne({ MO: MoId }, null, function(err, records) {
        if (err) {
            var newErr = new Error();
            newErr.leval = 9;
            newErr.title = '查询错误';
            newErr.message = '查询看板需求错误，请检查查询参数！';
            completeFun(newErr);
        } else {
            completeFun(null, records);
        }
    });
};
 
//根据条件获取看板信息
exports.findRecordsByCondition = function(condition, completeFun) {
    var entity = entityCollection.getEntity("KanbanDemand");
    entity.find(condition, null, [{
        path: "MO",
        select: "Code LotNumber"
    }], function(err, records) {
        if (err) {
            var newErr = new Error();
            newErr.leval = 9;
            newErr.title = '查询错误';
            newErr.message = '查询看板错误，请检查查询参数！';
            completeFun(newErr);
        } else {
            completeFun(null, records);
        }
    });
}